<template>
	<view class="content">
		<u--image :showLoading="true" :src="src" width="750rpx" height="600rpx" @click="click"></u--image>
		<u-gap height="20rpx" bgColor="#f5f5f5"></u-gap>
		<view class="ui_lable">
			<view class="ui_tip"></view>
			<view class="ui_text">产品信息</view>
		</view>
		<view class="ui_info">
			<view class="left">产品名称：</view>
			<view class="right">{{info.name}}</view>
		</view>
		<view class="ui_info">
			<view class="left">产品商标：</view>
			<view class="right">{{info.trademark}}</view>
		</view>
		<view class="ui_info">
			<view class="left">产品产地：</view>
			<view class="right">{{info.origin}}</view>
		</view>
		<view class="ui_info">
			<view class="left">产品企业：</view>
			<view class="right">{{info.enterprise.name}}</view>
		</view>
		<view class="ui_lable" v-if="batch">
			<view class="ui_tip"></view>
			<view class="ui_text">批次信息</view>
		</view>
		<view class="ui_info">
			<view class="left">采摘日期：{{batch.pick_date}}</view>
			<view class="right"></view>
		</view>
		<view class="ui_info">
			<view class="left">标签编号：</view>
			<view class="right">{{batch.serial_number}}</view>
		</view>
		<view class="ui_lable">
			<view class="ui_tip"></view>
			<view class="ui_text">认证信息</view>
		</view>
		<view class="img_info"  @click="nav_go('/pages/index/product_detail')">
			<u--image :showLoading="true" :src="src" width="260rpx" height="180rpx" radius="10rpx" @click="click"></u--image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				src: 'https://img2.baidu.com/it/u=2112311137,2912593221&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500',
				code:'',
				info:null,
				batch:{},
				certificate:{}
			}
		},
		onLoad(obj) {
			console.log(obj)
			if(obj.id){
				this.code = obj.id
			}
			uni.setStorageSync('code',this.code)
			this.load_info()
		},
		methods: {
			nav_go(url) {
				console.log(url)
				this.$util.navTo(url)
			},
			load_info(){
				this.$http.req('get', "traceability/code/"+this.code, {}, this).then(res => {
					var data = res.data.data
					if (res.data.code == 200) {
						console.log(data)
						this.info = data.product
						this.batch = data.batch
						this.certificate = data.certificate
						uni.setStorageSync('enterprise',data.product.enterprise)
					}
				})
			}
		}
	}
</script>

<style lang="less">
	.content {
		width: 750rpx;
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		.ui_lable{
			width: 690rpx;
			height: 70rpx;
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			margin-top: 20rpx;
			font-size: 30rpx;
			color: #333333;
			.ui_tip{
				width: 10rpx;
				height: 30rpx;
				border-radius: 5rpx;
				background-color: #333333;
				margin-right: 20rpx;
			}
			.ui_text{
				font-weight: bold;
			}
		}
		.ui_info{
			margin-bottom: 10rpx;
			display: flex;
			font-size: 28rpx;
			width: 610rpx;
			.right{
				color: #666;
			}
		}
		.img_info{
			width: 690rpx;
		}
	}
</style>
